package spring.cloud.tasks.tasks_manager.task_item_assign.pick_up.task;

import lombok.Getter;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
import spring.cloud.tasks.common.curator.Curator;
import spring.cloud.tasks.common.task_item_allot.Executor;
import spring.cloud.tasks.common.task_item_allot.TaskItem;
import spring.cloud.tasks.tasks_manager.task_item_assign.PreferExecutorSettings;
import spring.cloud.tasks.tasks_manager.task_item_assign.pick_up.PickUp;

import java.util.List;

/**
 * 任务启用，获取该任务的shards，注意要过滤不能运行该任务的executors
 */
@Slf4j
@Setter
@Getter
public class PickUpWhenTaskEnable extends PickUp {

    private String taskId;


    @Override
    protected void log() {
        log.info("Execute the {} with {} enable", this.getClass().getSimpleName(), taskId);
    }


    @Override
    public boolean pickUp(Curator curator,//
                          List<String> taskIdList,//
                          List<String> enableTaskIdList,//
                          List<TaskItem> pickUpEdTaskItemList,//
                          List<TaskItem> discardTaskItemList,//
                          List<Executor> onlineExecutorList,//
                          List<Executor> ownTrafficOnlineExecutorList,//
                          PreferExecutorSettings preferExecutorSettings) throws Exception {
        return false;//直接主类进行任务分配
/**
 * <pre>
 * //先移除清理
 *         TaskItemAssignUtils.removeTaskItemListOfTask(ownTrafficOnlineExecutorList, taskId);
 *         //获取支持该task的Executor
 *         TaskItemAssignUtils.refreshOnlineExecutorSupportedTaskIdList(curatorFramework, onlineExecutorList, taskId);
 *         //重新创建
 *         WaitedAssignTaskInfo waitedAssignTaskInfo = new WaitedAssignTaskInfo();
 *         pickUpEdTaskItemList.addAll(TaskItemAssignUtils.createTaskItemList(curatorFramework, waitedAssignTaskInfo));
 *
 *         return true;
 * </pre>
 */
    }


}
